//
//  LBDouyinCommentScrollController.m
//  TEXT
//
//  Created by mac on 2024/7/7.
//  Copyright © 2024 刘博. All rights reserved.
//

#import "LBDouyinCommentScrollController.h"
#import "LBDouyinCell.h"
#import "LBFunctionTestHeader.h"

@interface LBDouyinCommentScrollController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation LBDouyinCommentScrollController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.tableView];
    [self.tableView reloadData];
    self.view.backgroundColor = [UIColor cyanColor];
    // Do any additional setup after loading the view.
}

#pragma mark - UITableViewDelegate, UITableViewDataSource

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LBDouyinCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([LBDouyinCell class])];
    cell.contentView.backgroundColor = [UIColor cyanColor];
    NSString *title = [NSString stringWithFormat:@"这里是第%ld条内容", indexPath.row + 1];
    [cell updateWithTitle:title];
    cell.parentTableView = tableView;
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return ScreenHeight - 100;
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    NSLog(@"哈哈哈哈外层的scrollViewWillBeginDragging");
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"哈哈哈哈外层的外层的scrollViewDidScroll");
}

#pragma mark - lazy load

- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight - 100) style:UITableViewStylePlain];
        _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        [_tableView registerClass:[LBDouyinCell class] forCellReuseIdentifier:NSStringFromClass([LBDouyinCell class])];
        _tableView.dataSource = self;
        _tableView.pagingEnabled = YES;
        _tableView.delegate = self;
    }
    return _tableView;
}

@end
